<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>监听器语法</title>
    <script src="/js/vue.js"></script>
</head>
<body>
    <div id="app"></div>

</body>

<script>
   let vm=new Vue({
      el:'#app',
      data:{
        val: "简单对象初始值",
        obj: {
            name: "复杂对象name",
            value: "复杂对象value"
        }
      },
      watch: {
        //watch 监听器监听的值对应的函数的参数可加可不加，看需要
        val: function (newval,oldval) {
            console.log(newval,oldval);
            console.log(this.val);
        },
        obj:{
            deep: true,
            handler: function(new_val,old_val){
                console.log(new_val,old_val);
            }
        }
      }
   })
</script>

</html>